package com.letoo.dragon.core.spring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;

@Service
public class InitializeService implements ApplicationListener<ContextRefreshedEvent> {
	/**
	 * 日志
	 */
	private final Logger log = LoggerFactory.getLogger(getClass());

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		if (event.getApplicationContext().getParent() == null) {
			ApplicationContext applicationContext = event.getApplicationContext();

			// 加载数据库到redis缓存中
			loadDataToCache();
		}
	}

	/**
	 * 将数据加载到缓存中
	 */
	public void loadDataToCache() {
		log.info("启动系统初始化APP基本配置信息到缓存中-------开始");

		log.info("启动系统初始化APP基本配置信息到缓存中-------结束");
	}

}
